<?
class Conta {

	private	$data 			= array();
	private $lista_pers		= ListaDeElementos;
	private $pers_actual	= null;

	function __construct ($username, $unencrypted_pass, $email, $nivel) {
		$this->data['id']				= rand(1,999999);
		$this->data['username']			= $username;
		$this->data['nome']				= $username;
		$this->data['unencrypted_pass'] = $unencrypted_pass;
		$this->data['email']			= $email;
		$this->data['nivel']			= $nivel;
		$this->data['estado']			= 0;
		$this->data['data_reg']			= date('Y-m-d');
		$this->data['data_login']		= date('Y-m-d');
		$this->data['ultimo_acesso']	= floor(time());
		$this->data['max_npers']		= 1;
		
		$this->lista_pers	= new ListaDeElementos();
		$this->pers_actual	= null;
	}
	
	public function getActualPers () {
		return $this->pers_actual;
	}
	
	public function setActualPers($nome) {
		$this->pers_actual = $nome;
	}
	
	public function actualizarTempo($tempo) {
		$this->data['ultimo_acesso'] = $tempo;
	}
	
	public function addPers ($tpers) {
		$this->lista_pers->adiciona($tpers->getValue('nome'));
		$this->pers_actual = $tpers;
	}
	
	public function deletePers ($tpers) {
		if ($this->lista_pers->remover($tpers->getValue('nome')))
			return true;
		else return false;
	}
	
	public function getValue($key) {
		return $this->data[$key];
	}
	
	public function toArray() {
		return $this->data;
	}
}
?>